package cn.qicaiwang.open.websocket.config;


import cn.qicaiwang.open.common.constant.Constants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author : JCccc
 * @CreateTime : 2019/9/3
 * @Description :
 **/
@Configuration
public class RabbitDirectConsumerConfig {
    @Bean
    public Queue crmConsumerDirectQueue() {
        return new Queue(Constants.RABBITMQ_DEFAULT_QUEUE,true);
    }
 
    //Direct交换机
    @Bean
    DirectExchange crmConsumerDirectExchange() {
        return new DirectExchange(Constants.RABBITMQ_DEFAULT_DIRECT_EXCHANGE);
    }
 
    //绑定：将队列和交换机绑定，并设置用于匹配键
    @Bean
    Binding bindingConsumerDirect() {
        return BindingBuilder.bind(crmConsumerDirectQueue()).to(crmConsumerDirectExchange()).with(Constants.RABBITMQ_DEFAULT_DIRECT_ROUTING);
    }
}